var layer;
var form;
var carousel;
layui.use([ 'layer', 'form', 'carousel' ], function() {
	layer = layui.layer;
	form = layui.form;
	carousel = layui.carousel;
	
	// 监听浏览器变化
	windSize();
	
	carousel.render( {
		elem : '#test1',
		width : '100%',
		height : '100%',
		full : true,
		interval:3000,
		autoplay : true,
		arrow : 'none' // 始终显示箭头
		,anim: 'updown' //切换动画方式
	});

	form.on('submit(login)', function(data) {
		var text = sbumitLoading('.lay-submit-btn');
		data.field['password'] = aesMinEncrypt(data.field['password']);// 加密传输
		$.post($projectPath+'/loginJudge', data.field, function(res) {
			layer.msg(res.msg,{offset:'32%'});
			if(res.success){
				window.location.href = $projectPath+"/jumpMain";
			}else{
				openCode();
			}
			closeLoading('.lay-submit-btn', text);
		})
		return false;
	});
});

/**
 * 防止页面后退-------------------------------------------------------------------
 */
window.history.go(1);
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function() {
	history.pushState(null, null, document.URL);
});
if (window != top) {  
    top.location.href = location.href;  
}

/**
 * 监听浏览器变化（兼容窗口）---------------------------------------------------------
 */
$(window).resize(function(){
	windSize();
})
function windSize(){
	var w = $(document).width();
	if(w < 1100){
		$(".beg-login-box").addClass('app-form');
		$(".img_left").css('display', 'none');
	}else{
		$(".beg-login-box").removeClass('app-form');
		$(".img_left").css('display', 'inline-block');
	}
}

/**
 * 提交按钮加载中--------------------------------------------------------------
 * 
 * @param tab
 * @returns
 */
function sbumitLoading(tab){
	var tempText = $(tab).text();
	$(tab).html(tempText+'<i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop layui-ext-icon-selected-icon"></i>');
	$(tab).css('pointer-events', 'none');
	$(tab).addClass("layui-btn-disabled").attr("disabled", true);
	return tempText;
}
/**
 * 关闭提交按钮的加载中----------------------------------------------------------
 * 
 * @param tab
 * @param text
 * @returns
 */
function closeLoading(tab, text){
	$(tab).html(text);
	$(tab).css('pointer-events', 'auto');
	$(tab).removeClass("layui-btn-disabled").attr("disabled", false);
}




